home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-02-01 | 2.6 KB | 61 lines | [TEXT/MPS ] |
- PROCEDURE DoWZoom(theWindow: WindowPtr; zoomDir: INTEGER);
- VAR
- globalPortRect, theSect, zoomRect : Rect;
- nthDevice, dominantGDevice : GDHandle;
- sectArea, greatestArea : LONGINT;
- bias : INTEGER;
- sectFlag : BOOLEAN;
- BEGIN
- { theEvent is a global EventRecord from the main event loop }
- { savePort is a global GrafPtr for scratch }
- IF TrackBox(theWindow,theEvent.where,zoomDir) THEN
- BEGIN
- GetPort(savePort);
- SetPort(theWindow);
- EraseRect(theWindow^.portRect); {recommended for cosmetic reasons}
-
- { If there is the possibility of multiple gDevices, then we }
- { must check them to make sure we are zooming onto the right }
- { display device when zooming out. }
- { sysConfig is a global SysEnvRec set up during initialization }
- IF (zoomDir = inZoomOut) AND sysConfig.hasColorQD THEN
- BEGIN
- { window's portRect must be converted to global coordinates }
- globalPortRect := theWindow^.portRect;
- LocalToGlobal(globalPortRect.topLeft);
- LocalToGlobal(globalPortRect.botRight);
- { must calculate height of window's title bar }
- bias := globalPortRect.top - 1
- - WindowPeek(theWindow)^.strucRgn^^.rgnBBox.top;
- nthDevice := GetDeviceList;
- greatestArea := 0;
- { This loop checks the window against all the gdRects in the }
- { gDevice list and remembers which gdRect contains the largest }
- { portion of the window being zoomed. }
- WHILE nthDevice <> NIL DO
- BEGIN
- sectFlag := SectRect(globalPortRect,nthDevice^^.gdRect,theSect);
- WITH theSect DO
- sectArea := LONGINT(right - left) * (bottom - top);
- IF sectArea > greatestArea THEN
- BEGIN
- greatestArea := sectArea;
- dominantGDevice := nthDevice;
- END;
- nthDevice := GetNextDevice(nthDevice);
- END; {of WHILE}
- { We must create a zoom rectangle manually in this case. }
- { account for menu bar height as well, if on main device }
- IF dominantGDevice = GetMainDevice THEN
- bias := bias + GetMBarHeight;
- WITH dominantGDevice^^.gdRect DO
- SetRect(zoomRect,left+3,top+bias+3,right-3,bottom-3);
- { Set up the WStateData record for this window. }
- WStateDataHandle(WindowPeek(theWindow)^.dataHandle)^^.stdState := zoomRect;
- END; {of Color QuickDraw conditional stuff}
-
- ZoomWindow(theWindow,zoomDir,TRUE);
- SetPort(savePort);
- END;
- END;
-